//
//  PushSettingViewController.m
//  TTAddressBook
//
//  Created by WangJuan on 12-1-10.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "PushSettingViewController.h"
#import "SettingConstants.h"

@implementation PushSettingViewController
@synthesize stateLabel;
@synthesize stateButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
    if (self) 
    {
        self.title = @"新消息通知";
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //返回按钮
    UIBarButtonItem *goBackButton = [[UIBarButtonItem alloc]
                                     initWithTitle:@"返回"
                                     style:UIBarButtonItemStylePlain
                                     target:self
                                     action:@selector(goBackClick)];
    self.navigationItem.leftBarButtonItem = goBackButton;
    [goBackButton release];
    
    if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 5.0)
    {
        [goBackButton setBackgroundImage:[UIImage imageNamed: kNavigationBarButtonPng] forState:(UIControlStateNormal) barMetrics:0];
        [goBackButton setBackgroundImage:[UIImage imageNamed: kNavigationBarButtonOnPng] forState:(UIControlStateSelected) barMetrics:0];
    }
    
    UIImageView *backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    backgroundView.image = [UIImage imageNamed:kSettingBackGroundPng];
    [self.view addSubview:backgroundView];
    [self.view sendSubviewToBack:backgroundView];
    [backgroundView release];
    
    NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    
    if ( rntypes == UIRemoteNotificationTypeNone )
    {
        self.stateLabel.text = @"已关闭";
    }
    else
    {
        self.stateLabel.text = @"已开启";
    }
}

- (void)viewDidUnload
{
    [self setStateLabel:nil];
    [self setStateButton:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc 
{
    [stateLabel release];
    [stateButton release];
    [super dealloc];
}

- (void)goBackClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
